﻿using CompanyManageSystem.DLL;
using CompanyManageSystem.Service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CompanyManageSystem.UI.Repast
{
    public partial class Frm_PurchaseStorageOrder : BaseXtraForm
    {
        public Frm_PurchaseStorageOrder()
        {
            InitializeComponent();

            this.BindCheckEdit(gridView1,false,true);
            this.BindRowIndicator(gridView1);
        }

        /// <summary>
        /// 窗体加载完成
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Frm_PurchaseStorageOrder_Load(object sender, EventArgs e)
        {
            RepastService rservice = new RepastService();
            gridControl1.DataSource = rservice.GetAllStorageOrder();
            repositoryItemSearchLookUpEdit1.DataSource = rservice.GetAllSuppliers();
        }

        /// <summary>
        /// 增加
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Frm_PurchaseStorageOrderDetail frm = new Frm_PurchaseStorageOrderDetail(status:EStatus.Add);
            frm.SaveEvent += StorageDetail_SaveEvent;
            frm.ShowDialog();
        }
        private void StorageDetail_SaveEvent(Object sender,EventArgs e)
        {
            RepastService rservice = new RepastService();
            gridControl1.DataSource = rservice.GetAllStorageOrder();
            ShowInfo("保存成功!");
        }

        /// <summary>
        /// 导出Excel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barButtonItem11_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            this.ExportToExcel(gridControl1);
        }
    }
}
